home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / PowerPC / WarpUP3.1 / WarpUP-WarpOS / WarpRace / ModSrc / C2P.p next >
Text File  |  1997-09-24  |  9KB  |  261 lines

  1.  
  2.                 incdir  include:
  3.                 incdir  powerasm:source/powerpc_lib/warprace/
  4.                 incdir  lvo:
  5.  
  6. **      '(C) Copyright 1997 Haage & Partner Computer GmbH'
  7. **           All Rights Reserved
  8.  
  9.                 include graphics/gfx.i
  10.                 include powerpc/ppcmacros.i
  11.                 include powerpc/powerpc.i
  12.                 include warprace.i
  13.  
  14.                 include powerpc_lib.i
  15.  
  16.                 xref    _PowerPCBase
  17.                 xref    ChunkyBuffer
  18.                 xref    bitmap
  19.  
  20.                 xdef    C2P_PPC
  21.  
  22.                 section "",code
  23.  
  24.                 cpu     POWERPC
  25.                 smalldata
  26.  
  27.  
  28. merge           macro
  29.                 and     r18,\1,\3
  30.                 xor     \1,r18,\1
  31.                 and     r19,\2,\3
  32.                 xor     \2,r19,\2
  33.                 slwi    r18,r18,\4
  34.                 srwi    \2,\2,\4
  35.                 or      \1,\1,\2
  36.                 or      \2,r19,r18
  37.                 endm
  38.  
  39.  
  40. C2P_PPC
  41.                 prolog
  42.                 push    r31
  43.                 mr      r31,r5
  44.                 lwz     r3,WRI_STARTTIMER_PPC(r31)
  45.                 mtlr    r3
  46.                 lwz     r3,WRI_LINKERDB(r31)
  47.                 blrl
  48.                 li      r3,50
  49.                 mtctr   r3
  50. .loop
  51.                 lw      r3,ChunkyBuffer
  52.                 la      r4,bitmap
  53.                 bl      ChunkyToPlanar_PPC
  54.                 bdnz    .loop
  55.                 lwz     r3,WRI_STOPTIMER_PPC(r31)
  56.                 mtlr    r3
  57.                 lwz     r3,WRI_LINKERDB(r31)
  58.                 blrl
  59.                 li      r4,50
  60.                 divwu   r3,r3,r4
  61.                 pop     r31
  62.                 epilog
  63.  
  64. ******************************************************************************
  65. *
  66. *       ChunkyToPlanar_PPC (r3,r4)
  67. *
  68. *       converts chunky data into bitplane data (using Bitmap Structure)
  69. *       works ONLY with a depth of 8 and resolution of 320*256!
  70. *
  71. *       original algorithm by James McCoull (I found the source somewhere
  72. *       on the AMINET CD's)
  73. *
  74. *       In:  r3 -> ChunkyBuffer
  75. *            r4 -> bitmap structure
  76. *
  77. ******************************************************************************
  78. ChunkyToPlanar_PPC
  79.                 prolog  256
  80.                 pushgpr r14-r28
  81.                 subi    local,local,32          ; space for temporary variables
  82.                 mr      r5,r3
  83.                 mr      r3,r4
  84.                 la      r3,bm_Planes+32(r3)     ;r11 -> after 8 plane ptrs
  85.                 lwzu    r16,-4(r3)              ;read 8 plane ptrs
  86.                 lwzu    r15,-4(r3)
  87.                 lwzu    r14,-4(r3)
  88.                 lwzu    r28,-4(r3)
  89.                 lwzu    r12,-4(r3)
  90.                 lwzu    r11,-4(r3)
  91.                 lwzu    r10,-4(r3)
  92.                 lwzu    r9,-4(r3)
  93.                 subi    r9,r9,4                 ;prepare for postincrement
  94.                 subi    r10,r10,4
  95.                 subi    r11,r11,4
  96.                 subi    r12,r12,4
  97.                 subi    r28,r28,4
  98.                 subi    r14,r14,4
  99.                 subi    r15,r15,4
  100.                 subi    r16,r16,4
  101.                 mr      r3,r5
  102.  
  103. ; r3 = chunky buffer
  104. ; r9-r16 = output area
  105.  
  106.                 liw     r5,320*256
  107.                 add     r4,r3,r5                ;r4 -> end of chunky data
  108.                 liw     r5,$00ff00ff            ;load mask values
  109.                 liw     r6,$0f0f0f0f
  110.                 liw     r7,$33333333
  111.                 liw     r8,$55555555
  112. first_case
  113.                 lwz     r21,0(r3)
  114.                 lwz     r23,4(r3)
  115.                 lwz     r20,8(r3)
  116.                 lwz     r22,12(r3)
  117.                 lwz     r24,2(r3)
  118.                 lwz     r25,10(r3)
  119.                 lwz     r26,6(r3)
  120.                 lwz     r27,14(r3)
  121.                 lhz     r17,16(r3)
  122.                 mh      r21,r17
  123.                 lhz     r17,24(r3)
  124.                 mh      r20,r17
  125.                 lhz     r17,20(r3)
  126.                 mh      r23,r17
  127.                 lhz     r17,28(r3)
  128.                 mh      r22,r17
  129.                 lhz     r17,18(r3)
  130.                 mh      r24,r17
  131.                 lhz     r17,26(r3)
  132.                 mh      r25,r17
  133.                 lhz     r17,22(r3)
  134.                 mh      r26,r17
  135.                 lhz     r17,30(r3)
  136.                 mh      r27,r17
  137.                 addi    r3,r3,32
  138.  
  139.                 merge   r21,r20,r5,8            ;now convert it
  140.                 merge   r23,r22,r5,8
  141.                 merge   r21,r23,r6,4
  142.                 merge   r20,r22,r6,4
  143.                 merge   r24,r25,r5,8
  144.                 merge   r26,r27,r5,8
  145.                 merge   r24,r26,r6,4
  146.                 merge   r25,r27,r6,4
  147.                 merge   r23,r26,r7,2
  148.                 merge   r22,r27,r7,2
  149.                 merge   r23,r22,r8,1
  150.                 merge   r26,r27,r8,1
  151.                 merge   r21,r24,r7,2
  152.                 merge   r20,r25,r7,2
  153.                 merge   r21,r20,r8,1
  154.                 merge   r24,r25,r8,1
  155.  
  156.                 stw     r27,0*4(local)          ;plane 0
  157.                 stw     r26,1*4(local)          ;plane 1
  158.                 stw     r22,2*4(local)          ;plane 2
  159.                 stw     r23,3*4(local)          ;plane 3
  160.                 stw     r25,4*4(local)          ;plane 4
  161.                 stw     r24,5*4(local)          ;plane 5
  162.                 stw     r20,6*4(local)          ;plane 6
  163.                 stw     r21,7*4(local)          ;plane 7
  164.  
  165.                 cmpw    r4,r3
  166.                 beq     final_case
  167. main_case
  168.                 lwz     r21,0(r3)
  169.                 lwz     r23,4(r3)
  170.                 lwz     r20,8(r3)
  171.                 lwz     r22,12(r3)
  172.                 lwz     r24,2(r3)
  173.                 lwz     r25,10(r3)
  174.                 lwz     r26,6(r3)
  175.                 lwz     r27,14(r3)
  176.                 lhz     r17,16(r3)
  177.                 mh      r21,r17
  178.                 lhz     r17,24(r3)
  179.                 mh      r20,r17
  180.                 lhz     r17,20(r3)
  181.                 mh      r23,r17
  182.                 lhz     r17,28(r3)
  183.                 mh      r22,r17
  184.                 lhz     r17,18(r3)
  185.                 mh      r24,r17
  186.                 lhz     r17,26(r3)
  187.                 mh      r25,r17
  188.                 lhz     r17,22(r3)
  189.                 mh      r26,r17
  190.                 lhz     r17,30(r3)
  191.                 mh      r27,r17
  192.                 addi    r3,r3,32
  193.  
  194.                 lwz     r17,0*4(local)
  195.                 stwu    r17,4(r9)
  196.                 merge   r21,r20,r5,8
  197.                 merge   r23,r22,r5,8
  198.                 lwz     r17,1*4(local)
  199.                 stwu    r17,4(r10)
  200.                 merge   r21,r23,r6,4
  201.                 merge   r20,r22,r6,4
  202.                 lwz     r17,2*4(local)
  203.                 stwu    r17,4(r11)
  204.                 merge   r24,r25,r5,8
  205.                 merge   r26,r27,r5,8
  206.                 lwz     r17,3*4(local)
  207.                 stwu    r17,4(r12)
  208.                 merge   r24,r26,r6,4
  209.                 merge   r25,r27,r6,4
  210.                 lwz     r17,4*4(local)
  211.                 stwu    r17,4(r28)
  212.                 merge   r23,r26,r7,2
  213.                 merge   r22,r27,r7,2
  214.                 lwz     r17,5*4(local)
  215.                 stwu    r17,4(r14)
  216.                 merge   r23,r22,r8,1
  217.                 merge   r26,r27,r8,1
  218.                 lwz     r17,6*4(local)
  219.                 stwu    r17,4(r15)
  220.                 merge   r21,r24,r7,2
  221.                 merge   r20,r25,r7,2
  222.                 lwz     r17,7*4(local)
  223.                 stwu    r17,4(r16)
  224.                 merge   r21,r20,r8,1
  225.                 merge   r24,r25,r8,1
  226.                 stw     r27,0*4(local)          ;plane 0
  227.                 stw     r26,1*4(local)          ;plane 1
  228.                 stw     r22,2*4(local)          ;plane 2
  229.                 stw     r23,3*4(local)          ;plane 3
  230.                 stw     r25,4*4(local)          ;plane 4
  231.                 stw     r24,5*4(local)          ;plane 5
  232.                 stw     r20,6*4(local)          ;plane 6
  233.                 stw     r21,7*4(local)          ;plane 7
  234.  
  235.                 cmpw    r4,r3
  236.                 bne     main_case
  237.  
  238. final_case
  239.                 lwz     r17,0*4(local)
  240.                 stwu    r17,4(r9)
  241.                 lwz     r17,1*4(local)
  242.                 stwu    r17,4(r10)
  243.                 lwz     r17,2*4(local)
  244.                 stwu    r17,4(r11)
  245.                 lwz     r17,3*4(local)
  246.                 stwu    r17,4(r12)
  247.                 lwz     r17,4*4(local)
  248.                 stwu    r17,4(r28)
  249.                 lwz     r17,5*4(local)
  250.                 stwu    r17,4(r14)
  251.                 lwz     r17,6*4(local)
  252.                 stwu    r17,4(r15)
  253.                 lwz     r17,7*4(local)
  254.                 stwu    r17,4(r16)
  255. exit
  256.                 addi    local,local,32
  257.                 popgpr
  258.                 epilog
  259.  
  260.  
  261.